<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>基本资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/ssm/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/ssm/css/public.css" media="all">
    <style>
        .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-form layuimini-form" lay-filter="personalForm">
            <div class="layui-form-item">
                <input type="hidden" name="id">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">昵称</label>
                <div class="layui-input-block">
                    <input type="text" name="nickname" lay-verify="required" lay-reqtext="昵称" placeholder="请输入昵称" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="男" title="男" checked="">
                    <input type="radio" name="sex" value="女" title="女">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">年龄</label>
                <div class="layui-input-block">
                    <input type="number" name="age"   placeholder="请输入年龄" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">联系方式</label>
                <div class="layui-input-block">
                    <input type="text" name="tel" lay-verify="required" lay-reqtext="手机不能为空" placeholder="请输入手机" value="" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/ssm/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/ssm/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form','miniTab'], function () {
        let form = layui.form,
            layer = layui.layer,
            $ = layui.$,
            miniTab = layui.miniTab;

        // 个人信息回显
        let username = sessionStorage.getItem("username");
        // 发送请求 获取用户的个人信息
        $.get("/ssm/user/personInfo/"+username,function (res){
                if (res.code==0){
                    form.val("personalForm",res.data)
                    // 重新渲染表单
                    form.render()
                }
        })

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            let  formData = data.field
            $.post("/ssm/user/editPersonalInfo",formData,function (res){
                if (res.code==0){
                    layer.msg(res.msg,{icon:1},function (){
                        miniTab.deleteCurrentByIframe();  //  删除tab栏
                    })
                }else{
                    layer.msg(res.msg,{icon:2})
                }
            })
            return false;
        });

    });
</script>
</body>
</html>